let sessionSelfComponent = {
    template: `
        <div class="sessionSelf page">
            <div class="head">
                 <div class="left" @click="back">
                    <span class="iconfont icon-ali-fanhui"></span>
                </div>
                <div class="title">{{title}}</div>
                <div class="right"></div>
            </div>
            <div class="info">
                <div class="item">
                    <div class="label">name:</div>
                    <div class="value">{{info.name}}</div>
                </div>
                <div class="item">
                    <div class="label">author:</div>
                    <div class="value">{{info.description}}</div>
                </div>
                <div class="item">
                    <div class="label">publishTime:</div>
                    <div class="value">{{info.publishTime}}</div>
                </div>
            </div>
            <div class="main">
                
               <div class="content">
                   <div class="item" v-for="item in categoryList" @click="handleView(item)">
                        <div class="item-name">
                            startTime:{{item.startTime}}
                        </div>
                       <div class="item-name">
                            endTime:{{item.endTime}}
                        </div>
                    </div>
               </div>

          
            </div>
        </div>
    `,
    data() {
        return {
            categoryList:[],
            filter:{
                name:null,
                description:null
            },
            title:null,
            info: window.sessionSelf || {}
        }

    },
    computed: {},
    watch: {},
    mounted() {
        this.title = this.$route.name

        this.fetchDataList()
    },
    activated() {

    },
    methods: {
        back(){
            this.$router.back()
        },
        handleDelete(){

        },
        handleEdit(item){
            this.$router.push({
                name: 'sections',
                query:{
                    sessionId: item.id
                }
            })
        },
        fetchDataList(){
            let filter = {
                userId: user.user.id,
                sessionId: this.$route.query.sessionId
            }

            if(this.filter.description){
            }
            treatmentSession.getSelfInstancesList(JSON.stringify(filter)).then((entities)=>{

                entities.sort(function(a,b){return b.id-a.id})

                this.categoryList = entities
            })
        },
        update(state,item){
            treatmentSession.update({
                id: item.id,
                state
            }).then(()=>{
                item.state = state
            })
        },
        handleView(item){
            this.$router.push({
                name: 'result',
                query:{

                    sessionId: this.info.id
                }
            })
        }
    },
    components: {},
    beforeRouteLeave(to, from, next) {

        next();
    }
}

